package vip.xiaonuo.smzq.modular.lifecycle.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component;
import vip.xiaonuo.smzq.modular.lifecycle.vo.common.TreeFilterVO;

import java.util.List;
import java.util.Stack;

/**
 * HTOOL 扩展
 * @author GEOSCENE_YUYF
 */
@Component
public class HutoolExtend {
    /**
     * 往字符串的某个位置插入字符串
     * @param srcStr
     * @param inObj 插入的对象
     * @param position
     * @return
     */
  public  String inertStr(String srcStr,Object inObj,int position){
      StringBuilder stringBuilder = new StringBuilder(srcStr);
      stringBuilder.insert(position, Convert.toStr(inObj)); // 在指定位置插入字符串
      return stringBuilder.toString();
  }

  public <T> List<T> listPop(List<T> list,int popSize){
      Stack<T> stack =  Convert.convert(new TypeReference<Stack<T>>() {}, list);
      CollUtil.popPart(stack,popSize);
      return Convert.convert(new TypeReference<List<T>>() {}, stack);
  }
}
